package com.yanze.mvvmlearndemo.utils;

import android.content.Context;
import android.widget.Toast;

/**
 * Created by MrZheng on 2018/3/12.
 */

public class ToastUtils {
    private static Toast mToast;
    private static int time;

    public static void showToast(Context context, String msg) {
        time = Toast.LENGTH_SHORT;
        if (msg.length() > 7) {
            time = Toast.LENGTH_LONG;
        }
        if (mToast == null) {
            mToast = Toast.makeText(context, msg, time);
        }
        mToast.setText(msg);
        mToast.show();
    }
}
